import axios from 'axios'
import type {AxiosInstance,AxiosRequestConfig} from 'axios'
import {RequestConnfig,RequestInterceptors} from './type'

class myAxios{
    public instance:AxiosInstance;
    public interceptors?:RequestInterceptors
    constructor(config:RequestConnfig){
        //创建axios实例
       this.instance=axios.create(config)
       this.interceptors=config.interceptors

       this.instance.interceptors.request.use(
           this.interceptors?.requestLan,
           this.interceptors?.responseErr
       )

       this.instance.interceptors.response.use(
           this.interceptors?.responseLan,
           this.interceptors?.resquestErr
       )
    }
    request(){

        return this.instance
    }
}


export default myAxios